<template>
	<view class="infoDetail">
		<!-- <view v-for="item in infoDetailList" :key="item.id">{{item.content}}</view> -->
		<view class="title">{{infoDetailData.title}}</view>
		<view class="info">
			<text>发表时间：{{infoDetailData.add_time | formatTime}}</text>
			<text>浏览量：{{infoDetailData.click}}</text>
		</view>
		<view class="content">
			内容：<rich-text :nodes="infoDetailData.content"></rich-text>
		</view>
	</view>
</template>

<script>
	export default {
		name:'infoDetail',
		data(){
			return{
				infoDetailData:{}
			}
		},
		onLoad({id}){
			this.getInfoDetailList(id)
		},
		filters:{
			formatTime(date){
				const nt = new Date(date)
				return nt.getFullYear() + '-' + nt.getMonth().toString().padStart(2,0) + '-' + nt.getDay().toString().padStart(2,0)
			}
		},
		methods:{
			async getInfoDetailList(id){
				const res = await this.$myRequest({
					url:`/api/getnew/${id}`
				})
				console.log(res)
				this.infoDetailData = res.data.message[0]
			}
		}
	}
</script>

<style lang="scss" scoped>
	.infoDetail{
		padding: 15rpx;
		.title{
			text-align: center;
			font-size: 30rpx;
			font-weight: bold;
		}
		.info{
			display: flex;
			justify-content: space-between;
			font-size: 26rpx;
			margin-top: 10rpx;
		}
		.content{
			margin-top: 10rpx;
			font-size: 26rpx;
			padding: 5rpx;
		}
	}
</style>
